b_name='nalogi'
const_name='const'
pers_name='pers'
vals_name='sum'

year=2012

filename="NO_NDFL2_7721_7721_7721030981772101001_20130726_D9ABF932-E9FD-405C-831E-8F905B4DBF80.xml"

from sys import stderr, __stderr__
from datetime import datetime
from os import path
from tree import File, reader, corrector, writer

__dir__ = path.dirname(path.abspath(__file__))
path_error = path.join(__dir__, "export.log")
stderr = open(path_error, 'a')


stderr.write("\n\n--------------------------***-----------------------------\nExport has begun...\nLocal Date and Time: "+str(datetime.now())+"\n--------------------------***-----------------------------\n\n")

result=File(b_name, const_name, pers_name, vals_name, year)
writer(corrector(reader(result[0])), path.join(__dir__, result[2]+'.xml'))

stderr.write("\n"+str(datetime.now())+"  INFO : Finished export. Persons number changed from 0 to "+str(result[1])+".\n"+str(datetime.now())+"  INFO : Finished execution export with status: Completed successfully.\n\n\n")
stderr.write("\nNo errors logged.\n\n\n--------------------------***-----------------------------\nExport has finished...\nLocal Date and Time: "+str(datetime.now())+"\n--------------------------***-----------------------------\n\n\n\n\n")


stderr.close()
stderr = __stderr__